package pl.edu.pw.elka.jtrzasko.proz.warcaby.actions.server;

import javax.swing.JOptionPane;
import javax.swing.SwingUtilities;

import pl.edu.pw.elka.jtrzasko.proz.warcaby.messages.server.ServerMessage;
import pl.edu.pw.elka.jtrzasko.proz.warcaby.messages.server.ServerMessageGameOver;
import pl.edu.pw.elka.jtrzasko.proz.warcaby.view.ClientView;

public class ServerActionGameOver extends ServerAction {

	public void run(final ClientView clientView, final ServerMessage message) {
		SwingUtilities.invokeLater(new Runnable() {
			public void run() {

				if (((ServerMessageGameOver)message).getColor() == clientView.getClientColor()) {
					clientView.getTextClientStatus().setText("You lost!");
					JOptionPane.showMessageDialog(clientView, " You lost!",
							"Game Finished", JOptionPane.INFORMATION_MESSAGE);
				} else {
					clientView.getTextClientStatus().setText("You won!");
					JOptionPane.showMessageDialog(clientView, " You won!",
							"Game Finished", JOptionPane.INFORMATION_MESSAGE);
				}

			}
		});
	}

}
